<template>
    <div>
        <a-input-search v-model:value="rankName" placeholder="请输入职级信息" style="width: 200px; margin-bottom: 10px"
            @search="onSearch()" />

        <el-tree :data="data" :props="{ label: 'rankName', children: 'children' }" :expand-on-click-node="false"
            :filter-node-method="filterNode" ref="rankTreeRef" highlight-current :default-expand-all="false"
            @node-click="handleNodeClick" />
    </div>
</template>
<script setup>
import { rankClassifyList } from '../pages/company/data'
import useApp from '@/hooks'
const { $, proxy } = useApp()
// const deptList = ref(rankClassifyList);
const rankName = ref('')
const data = ref(rankClassifyList)
const props = defineProps({
    value: {
        type: [String, Number]
    }
})
const emit = defineEmits(['confirm'])

// deptList.getTree().then(res => {
//     data.value = res
// })

/** 节点单击事件 */
function handleNodeClick(data) {
    // console.log(data);
    emit('confirm', data.code)
}
/** 通过条件过滤节点  */
const filterNode = (value, data) => {
    console.log('filterNode', value, data);
    // if (!value) return true;
    // return data.rankName.indexOf(value) !== -1;
};
/** 根据名称筛选部门树 */
watch(rankName, (val) => {
    console.log(val);
    proxy.$refs["rankTreeRef"].filter(val);
});

function onSearch() {

}
</script>